package cn.org.tpeach.nosql.controller;

import javafx.fxml.FXML;
import javafx.fxml.Initializable;
import javafx.scene.control.Button;
import javafx.scene.control.Label;
import javafx.scene.image.Image;
import javafx.scene.image.ImageView;
import javafx.scene.layout.GridPane;
import javafx.scene.layout.HBox;


import java.net.URL;
import java.util.ResourceBundle;
import java.util.concurrent.atomic.AtomicBoolean;

/**
 * @author tyz
 * @Title: AboutController
 * @ProjectName Redis-Lettuce-Parent
 * @Description: TODO
 * @date 2020-06-08 9:07
 * @since 2.0.0
 */
public class AboutController implements Initializable {
    @FXML
    private GridPane aboutGridPane;
    @FXML
    private Button donationButton;
    @FXML
    private HBox aboutHomeImageHbox;
    @FXML
    private HBox  aboutAliHbox;
    @FXML
    private HBox   aboutWechatHbox;
    AtomicBoolean donate = new AtomicBoolean(false);
    @Override
    public void initialize(URL location, ResourceBundle resources) {
        ImageView imageView = new  ImageView("/view/img/home.png");
        ImageView alipay = new  ImageView(new Image("/view/img/pay/alipay.jpg", 230, 230, false, false));
        ImageView wechatpay = new  ImageView(new Image("/view/img/pay/wechatpay.jpg", 230, 230, false, false));
        aboutHomeImageHbox.getChildren().addAll(imageView);
        aboutAliHbox.getChildren().add(new Label("",alipay));
        aboutWechatHbox.getChildren().add(new Label("",wechatpay));
        aboutAliHbox.setVisible(false);
        aboutWechatHbox.setVisible(false);
        donationButton.setOnAction(event -> {
            boolean b = donate.getAndSet(!donate.get());
            aboutHomeImageHbox.setVisible(!b);
            aboutAliHbox.setVisible(b);
            aboutWechatHbox.setVisible(b);
        });
    }
}
